<?php
session_start();
include 'connect_db.php';

$sql="SELECT iditems,name FROM $table_items";
$result=mysql_query($sql);

//USERID
$sql="SELECT idusers FROM users_site WHERE email_adress='$myusername'";
$result1=mysql_query($sql);
$count=mysql_num_rows($result1);
if($count==1){
    while($tableau1=mysql_fetch_array($result1,MYSQL_ASSOC)){
        $userid =   $tableau1['idusers'];
        //echo "userID:";
        //echo $userid;
    }
}


while($tableau=mysql_fetch_array($result,MYSQL_ASSOC)){
    //session_register("vdrop".$tableau['iditems']);
    if($_POST['drop'.$tableau['iditems'] ]!='Ne pas modifier la note'){
        $temprating=intval($_POST['drop'.$tableau['iditems'] ]);
        $tempitem=intval($tableau['iditems']);

        $sql="DELETE FROM ratings WHERE users_idusers=".$userid." AND items_iditems=".$tempitem;
        mysql_query($sql);
        $sql="INSERT INTO ratings (rating,users_idusers,items_iditems) VALUES ($temprating,$userid,$tempitem)";
        mysql_query($sql);
    }
}
header("location:board.php");
mysql_close($link);
?>